home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-03
/
vb3ex.zip
/
VB3EX.FRM
(
.txt
)
< prev
next >
Wrap
Visual Basic Form
|
1992-03-01
|
7KB
|
167 lines
VB3EX
VISUAL BASICS #3 Example
Form1,
LblWinDir
Windows Directory:
LblMessages
TxtINIFile
LblINIFile
INI File:
TxtSection
LblSection
Section:
TxtKey
LblKey
TxtValue
LblValue
Value:
BtnWrite
&Write
BtnRead
&Read
BtnEdit
&&Edit
BtnQuit
&Quit
GetWindowsDirectory
lpBufferc
nSize6
GetPrivateProfileString
AppName
KeyName
Default
ReturnedString
MaxSize
FileName&
WritePrivateProfileString\
NewString
StringFromINIn
MaxStringLenO
ReturnedStr
Resultq
ResultStr
WriteItemToINI|
DataString
INIFileName
Form_Click#
WinDir
PathStringLength
WindowsPathName
Success
WindowsDirectory!
@ Form_Load]
MB_ICONINFORMATION
Label1
Captiong
Command3_ClickQ
BtnQuit_Clicky
BtnWrite_Clicky
BtnSection
BtnKey
StringToINI
Section
SectnL
TxtSection,
TxtKey
TxtValue4
Value
ShelRes>
ShellStr
LblWindir
LblINIFile
INIFileNam
Windows
Keyy:
ValyueP
TxtINIFile
FileNamE
Command1_Click
BtnRead_Click
DeeFalt
LblMessages
Screen
MousePointer
Launching
NOTEPAD
BtnEdit_Click2
BtnEdit_GotFocus
Form_GotFocus
SectionName
BtnRead
Enabled
TxtINIFile_Change
TxtINIFile_KeyPress
KeyAsciip
Windows API calls! Get 'em while they're hot!
learn about your environment
Kernelq
read/write your application's 'private' INI file
Kernel#
Kernel#
Form_Load
VB3EX.INI"
Windows Directory: "
BtnQuit_Click
BtnWrite_Click
Write FAILED."
Write SUCCEEDED.
StringToINI
StringFromINI
Function reads an item from an app's INI file.
-SectionName is the Application name
-KeyName is the Key to read from the ini file
-Default is the value to be supplied if the ini file doesn't exist or if the keym
hasn't been created/defined in the INI file.i
-ReturnedString is the string read from the INI file
-ReturnedStringLen is the max allowable length of ReturnedStrings
-FileName is the INI file name.
ALL OF THESE PARAMETERS MUST BE INITIALIZED for this API call to work.
TRIM OUT BLANKS
REMOVE CHR$(0) FROM END
WinDir
Author:
Barry Seymour, Vanguard Business Solutions
Date:
29Aug91
Globals used:
None
Functions Called: GetWindowsDirectory, defined in GLOBAL.BAS as follows:i
Declare Function GetWindowsDirectory Lib "Kernel" (ByVal lpBuffer As String, ByVal nSize As Integer) As Integere
Explanation: This Function returns a string containing the
name of the Windows directory. The GetWindowsDirectory
function call is defined in GLOBAL.BAS (see above)c
and uses a Windows API call to the Kernel.e
IMPORTANT NOTE: The string to contain the returned data MUST be fully
initialized prior to placing data in it, else an Unrecoverable
Application Error (UAE) will result. This Function initializes the
string with empty spaces so the result can be trimmed.i
EVEN SO, the result string has a null char at the end of it which
must be stripped away manually - RTrim$ or LTrim$ don't strip out
null chars.
ANOTHER IMPORTANT NOTE: If your windows directory is in the ROOT, a
backslash is at the end of the string ("C:\"). If not, there is no
backslash at the end of the string ("C:\WINDOWS").
Error trapping is also in this code, giving a STERN WARNING to the user.
If this procedure fails, your system is mightily confused.
linefeed for message formatting-
The length is arbitrary, but MUST be defined.-
Initialize the full string to SPACES. The full length of the-
string MUST be present before making the function call, else UAE!-
|--Trim trailing blanks |-Trim null char at end of string.E
C:\WINDOWS
SYSTEM ERROR: Unable to determine Windows Directory.
Error
Error Number Unknown."
Assuming Windows Directory to be C:\WINDOWS.
It is STRONGLY RECOMMENDED that you save your work "
and SHUT DOWN this application."
System Error
BtnRead_Click
Assign textbox contents to variables for API call.
(API call won't take references to Textbox contents.)
Section, Key or File name not found.
Read SUCCEEDED."
BtnEdit_Click
Editing
NOTEPAD.EXE